
<extend name="Common/public"/>

<block name="content">
<style>
	.search>ul{margin:0 auto;width:320px;}
	.search>ul>li{border:1px solid #ccc;border-radius:2px;}
	.search>ul>li>a{display:block;height:24px;line-height:24px;margin-left:7px;}
	.search>ul>li>a:hover{text-decoration: none;}
</style>
</head>
<body class="pos-r" style="position: relative;">
	<if condition="$cat_id gt 0">
	<div>
		<div class="text-c"> 日期范围：
			<input type="text" onfocus="WdatePicker()" id="logmin" class="input-text Wdate" style="width:120px;">
			-
			<input type="text" onfocus="WdatePicker()" id="logmax" class="input-text Wdate" style="width:120px;">
			<input type="text" name="" id="" placeholder=" 产品名称" style="width:250px" class="input-text">
			<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜产品</button>
		</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a class="btn btn-primary radius" onclick="product_add('添加商品','{:U('goodsAdd',array('cat_id'=>$_GET['cat_id']))}')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加商品</a></span> <span class="r">共有数据：<strong>54</strong> 条</span> </div>
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="40"><input name="" type="checkbox" value=""></th>
						<th width="40">ID</th>
						<th width="100">产品名称</th>
						<th width="100">分类名称</th>
						<th>描述</th>
						<th width="100">市场价格</th>
						<th width="100">本店价格</th>
						<th width="60">是否上架</th>
						<th width="100">操作</th>
					</tr>
				</thead>
				<tbody>
					<volist name="goods" id="v">
					<tr class="text-c va-m">
						<td><input name="" type="checkbox" value=""></td>
						<td>{$v['id']}</td>
						<td class="text-c">{$v['goods_name']}</td>
						<td class="text-c"><volist name="cats" id="c"><if condition="$c['id'] == $v['cat_id']">{$c['cat_name']}</if></volist></td>
						<td class="text-l">{$v['goods_desc']|htmlspecialchars_decode}</td>
						<td>{$v['market_price']}</td>
						<td>{$v['shop_price']}</td>
						<td class="td-status"><a onclick="changeSale(this,{$v['id']})"><img src="__PUBLIC__images/icon_<if condition='$v["is_on_sale"]==1'>right<else/>error</if>_s.png"/></a></td>
						<td class="td-manage">
						<a style="text-decoration:none" href="{:U('GoodsPhoto/photoList',array('goods_id'=>$v['id']))}" title="商品tupian"><i class="Hui-iconfont">&#xe613;</i></a> 
						<a style="text-decoration:none" class="ml-5" onClick="product_edit('商品编辑','{:U('goodsAdd',array('goods_id'=>$v['id'],'cat_id'=>$_GET['cat_id']))}','10001')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> 
						<a style="text-decoration:none" class="ml-5" onClick="product_del(this,'{:U('goods_del',array('goods_id'=>$v['id']))}')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
						</td>
					</tr>
					</volist>
				</tbody>
			</table>
		</div>
	</div>
	<else/>
	<div class="search" style="width:400px;height:160px;border: 1px solid #ccc;position: absolute;top: 50%;left: 50%;margin-top: -80px;margin-left: -200px;">
		<input id="search_cat" class="input-text radius" style="display:block;width: 320px;margin: 60px auto 0;" type="text" placeholder="请填写要搜索的栏目名称"/>
		<ul></ul>
	</div>
	</if>
<include file="Common/js"/>
<script type="text/javascript" src="__PUBLIC__lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="__PUBLIC__lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script> 
<script type="text/javascript">

// 修改产品是否上架
function changeSale(obj,goods_id){
	$.post('{:U("changeSale")}',{goods_id:goods_id},function(res){
		if(res == 'error'){
			layer.msg('修改失败，请稍后重试！',{icon:5,time:1000});return;
		}
		
		if(res == 1){ // 上架
			$(obj).find('img').prop('src','__PUBLIC__images/icon_right_s.png');
		}else{ // 下架
			$(obj).find('img').prop('src','/Public/Admin/images/icon_error_s.png');
		}
	});
}

$(function(){
	$('#search_cat').keyup(function(){
		var obj = this;
		var cat_name = $(this).val();
		$.post('{:U('searchCat')}',{cat_name:cat_name},function(html){
			$(obj).next().html(html);
		})
	});
})
var code;
		
function showCode(str) {
	if (!code) code = $("#code");
	code.empty();
	code.append("<li>"+str+"</li>");
}
		
$(document).ready(function(){
	var t = $("#treeDemo");
	//t = $.fn.zTree.init(t, setting, zNodes);
	demoIframe = $("#testIframe");
	//demoIframe.bind("load", loadReady);
	var zTree = $.fn.zTree.getZTreeObj("tree");
	//zTree.selectNode(zTree.getNodeByParam("id",'11'));
});

/*图片-添加*/
function product_add(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*图片-查看*/
function product_show(title,url,id){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*图片-编辑*/
function product_edit(title,url,id){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*图片-删除*/
function product_del(obj,url){
	layer.confirm('确认要删除吗？',function(index){
		$.get(url,function(res){
			if(res == 1){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			}else{
				layer.msg('删除失败，请重试!',{icon:5,time:1000});
			}
		})
		
	});
}
</script>
</body>
</block>